package com.wc.AlgoOJ_homework.AlgoOJ_BL2.C_完全二叉树的权值;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

/**
 * @Author congge
 * @Date 2024/4/1 19:01
 * @description http://43.138.190.70:8888/p/141?tid=6602a6e518e03a818a4bf047
 */
public class Main {
    static FastReader sc = new FastReader();
    static PrintWriter out = new PrintWriter(System.out);
    static int N = 100010, M = 25;
    static int[] t = new int[N << 1];
    static long[] s = new long[M];
    static int n;
    static int floor = 0;

    public static void main(String[] args) {
        n = sc.nextInt();
        Arrays.fill(t, -(int) 1e7);
        for (int i = 1; i <= n; i++) t[i] = sc.nextInt();
        dfs(1, 1);
        long maxV = s[1];
        int res = 1;
        for (int i = 2; i <= floor; i++) {
            if (maxV < s[i]) {
                res = i;
                maxV = s[i];
            }
        }
        out.print(res);
        out.flush();
    }

    static void dfs(int u, int floor) {
        if (t[u] == -(int) 1e7) return;
        Main.floor = Math.max(floor, Main.floor);
        s[floor] += t[u];
        dfs(u << 1, floor + 1);
        dfs(u << 1 | 1, floor + 1);
    }
}

class FastReader {
    StringTokenizer st;
    BufferedReader br;

    FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    String nextLine() {
        String s = "";
        try {
            s = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return s;
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }

    // 是否由下一个
    boolean hasNext() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                String line = br.readLine();
                if (line == null)
                    return false;
                st = new StringTokenizer(line);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return true;
    }
}
